package club.kingyin.pathfilter.config;

import club.kingyin.pathfilter.core.PathFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableConfigurationProperties(PathFilterProperties.class)
@ConditionalOnClass(PathFilter.class)
public class PathFilterConfig {

    @Autowired
    private PathFilterProperties pathFilterProperties;

    @Bean
    @ConditionalOnMissingBean
    PathFilter pathFilter() {
        return new PathFilter(pathFilterProperties.getPaths());
    }
}
